Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

285
Vistas
Vue and firebase project giving mean error of Property or method "state " is not defined on the instance but referenced during render
<template>
<div>
  <div class="view login" v-if="state.username === '' || state.username === null">
    <form class="login-form" @submit.prevent="Login">
      <div class="form-inner">
    <h1>Login to FireChat</h1>
       <label for="username">Username</label>
       <input type="text" v-model="inputUsername" placeholder="Please enter your username...">
       <input type="submit" value="Login">
    </div>
    </form>

  </div>

  <div class="view chat" v-else>
    <h1>Chat View</h1>
  </div>
  
</div>
</template>

<script>
import { reactive, onMounted, ref } from 'vue';
import db from './db';


export default {
  setup () {
    const inputUsername = ref("");
    const state = reactive({
      username: "",
      messages: []
    });
    
    const Login = () => {
      if (inputUsername.value != "" || inputUsername.value != null) {
        state.username = inputUsername.value;
        inputUsername.value = "";
      }
    }

     return {
      inputUsername,
      Login,
      state
    }
  }
}
</script>

I cant seem to figure out where am getting it wrong when state is defined I believe. the screen shows nothing. this code is literally from a tutorial i watched and exactly this worked even after getting code from the tutorial github repo it still shows this error

Property or method "state " is not defined on the instance but referenced during render.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Never used vue but i noticed that your script declares state however your script is loaded in the document after the div is because of the order you placed it.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda